<input type="text" name="" id="" />
<ul></ul>

<script src="./axios.js"></script>
<script>
  let iptTag = document.querySelector("input")
  let ulTag = document.querySelector("ul")
  iptTag.oninput = function () {
    let inputData = this.value
    let params = {
      prod: "pc",
      wd: this.value,
    }
    get("http://www.baidu.com/sugrec", params).then(
      (res) => {
        let data = res.g
        ulTag.innerHTML = ""
        let fragment = document.createDocumentFragment()
        data.forEach((item) => {
          let liTag = document.createElement("li")
          liTag.innerHTML = item.q
          fragment.appendChild(liTag)
        })
        ulTag.appendChild(fragment)
      },
      (err) => console.log(err)
    )
  }
</script>
